#pragma once

#include "stdafx.h"
#include "RootNode.h"

void RootNode::drawSelf(IDrawTool* tool){
	initBound(&this->textBound);

	tool->dc->DrawText( this->data.GetString(), this->data.GetLength(), this->textBound, DT_CALCRECT);

	// draw self
	this->bound.left	= this->point.x - (this->textBound.right - this->textBound.left ) / 2 - ROOT_WIDTH_MARGINE;
	this->bound.top		= this->point.y - (this->textBound.top - this->textBound.bottom) / 2 - ROOT_HEIGHT_MARGINE;
	this->bound.right	= this->point.x + (this->textBound.right - this->textBound.left ) / 2 + ROOT_WIDTH_MARGINE;
	this->bound.bottom	= this->point.y + (this->textBound.top - this->textBound.bottom) / 2 + ROOT_HEIGHT_MARGINE;

	// draw the border
	tool->dc->RoundRect(this->bound, CPoint(60, 60));

	tool->dc->DrawText(this->data.GetString(), this->data.GetLength(), this->bound, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
	return;
}


RootNode::RootNode(int ID, char* aStr, Node* parentNode):Node(ID, aStr, parentNode){
}

Node* RootNode::getParents(){
	return this;
}

Node* RootNode::deleteNode(Node* node){
	if( this == node ){
		return this;
	}else{
		return Node::deleteNode(node);
	}
}